/*
 * DebugDelete:
 * 1. 重载一个函数调用运算符
 * 2. 接受一个指针并对此指针执行delete
 * 3. 在调用删除时，打印消息
 */

#ifndef DEBUGDELETE_H_
#define DEBUGDELETE_H_

#include <iostream>

class DebugDelete {
public:
	DebugDelete(std::ostream &s = std::cerr): os(s) { }
	template <typename T> void operator() (T *p) const
		{ os << "deleting unique_ptr" << std::endl; delete p; }

private:
	std::ostream &os;
};

#endif /* DEBUGDELETE_H_ */

